package com.flxz.LLMConfig;

import com.alibaba.cloud.ai.dashscope.api.DashScopeApi;
import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatModel;
import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatOptions;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.ChatOptions;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SAALLMConfig {
    private final String dp_model = "deepseek-v3";
    private final String qwen_model = "qwen-max";

    @Bean(name="deepseek")
    public ChatModel deepseek(){
        return DashScopeChatModel.builder()
                .dashScopeApi(DashScopeApi.builder().apiKey(System.getenv("aliQwen_api"))
                        .build())
                .defaultOptions(DashScopeChatOptions.builder().withModel(dp_model).build())
                .build();
    }

    @Bean(name="qwen")
    public ChatModel qwen(){
        return DashScopeChatModel.builder()
                .dashScopeApi(DashScopeApi.builder()
                        .apiKey(System.getenv("aliQwen_api"))
                        .build())
                .defaultOptions(DashScopeChatOptions.builder().withModel(qwen_model).build())
                .build();
    }


    @Bean(name="dpChatClient")
    public ChatClient dpChatClient(@Qualifier("deepseek") ChatModel dp){
        return ChatClient.builder(dp)
                .defaultOptions(ChatOptions.builder().model(dp_model).build())
                .build();

    }

    @Bean(name="qwenChatClient")
    public ChatClient qwenChatClient(@Qualifier("qwen") ChatModel qwen){
        return ChatClient.builder(qwen)
                .defaultOptions(ChatOptions.builder().model(qwen_model).build())
                .build();
    }
}
